package com.woniu.jifen.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

/**
 * 优惠券
 * @TableName a_coupon
 */
@TableName(value ="a_coupon")
@Data
public class ACoupon implements Serializable {
    /**
     * 
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 适用商品ID
     */
    private Integer sortId;

    /**
     * 适用金额
     */
    private BigDecimal usageAmount;

    /**
     * 库存量   -1为无限兑换
     */
    private Integer total;

    /**
     * 是否可用
     */
    private Integer available;

    /**
     * 条件
     */
    private String conditions;

    /**
     * 不可用原因
     */
    private String reason;

    /**
     * 优惠价格
     */
    private BigDecimal value;

    /**
     * 优惠券名称
     */
    private String name;

    /**
     * 可用时间
     */
    @JsonFormat(pattern="yyyy-MM-dd")
    private Date startAt;

    /**
     * 到期时间
     */

    @JsonFormat(pattern="yyyy-MM-dd")
    private Date endAt;

    /**
     * 价格描述
     */
    private String valueDesc;

    /**
     * 单位
     */
    private String unitDesc;

    /**
     * 兑换所需积分
     */
    private Integer integral;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        ACoupon other = (ACoupon) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getSortId() == null ? other.getSortId() == null : this.getSortId().equals(other.getSortId()))
            && (this.getUsageAmount() == null ? other.getUsageAmount() == null : this.getUsageAmount().equals(other.getUsageAmount()))
            && (this.getTotal() == null ? other.getTotal() == null : this.getTotal().equals(other.getTotal()))
            && (this.getAvailable() == null ? other.getAvailable() == null : this.getAvailable().equals(other.getAvailable()))
            && (this.getConditions() == null ? other.getConditions() == null : this.getConditions().equals(other.getConditions()))
            && (this.getReason() == null ? other.getReason() == null : this.getReason().equals(other.getReason()))
            && (this.getValue() == null ? other.getValue() == null : this.getValue().equals(other.getValue()))
            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
            && (this.getStartAt() == null ? other.getStartAt() == null : this.getStartAt().equals(other.getStartAt()))
            && (this.getEndAt() == null ? other.getEndAt() == null : this.getEndAt().equals(other.getEndAt()))
            && (this.getValueDesc() == null ? other.getValueDesc() == null : this.getValueDesc().equals(other.getValueDesc()))
            && (this.getUnitDesc() == null ? other.getUnitDesc() == null : this.getUnitDesc().equals(other.getUnitDesc()))
            && (this.getIntegral() == null ? other.getIntegral() == null : this.getIntegral().equals(other.getIntegral()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getSortId() == null) ? 0 : getSortId().hashCode());
        result = prime * result + ((getUsageAmount() == null) ? 0 : getUsageAmount().hashCode());
        result = prime * result + ((getTotal() == null) ? 0 : getTotal().hashCode());
        result = prime * result + ((getAvailable() == null) ? 0 : getAvailable().hashCode());
        result = prime * result + ((getConditions() == null) ? 0 : getConditions().hashCode());
        result = prime * result + ((getReason() == null) ? 0 : getReason().hashCode());
        result = prime * result + ((getValue() == null) ? 0 : getValue().hashCode());
        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
        result = prime * result + ((getStartAt() == null) ? 0 : getStartAt().hashCode());
        result = prime * result + ((getEndAt() == null) ? 0 : getEndAt().hashCode());
        result = prime * result + ((getValueDesc() == null) ? 0 : getValueDesc().hashCode());
        result = prime * result + ((getUnitDesc() == null) ? 0 : getUnitDesc().hashCode());
        result = prime * result + ((getIntegral() == null) ? 0 : getIntegral().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", sortId=").append(sortId);
        sb.append(", usageAmount=").append(usageAmount);
        sb.append(", total=").append(total);
        sb.append(", available=").append(available);
        sb.append(", conditions=").append(conditions);
        sb.append(", reason=").append(reason);
        sb.append(", value=").append(value);
        sb.append(", name=").append(name);
        sb.append(", startAt=").append(startAt);
        sb.append(", endAt=").append(endAt);
        sb.append(", valueDesc=").append(valueDesc);
        sb.append(", unitDesc=").append(unitDesc);
        sb.append(", integral=").append(integral);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}